package com.manage.customer.provider;

import com.baomidou.mybatisplus.toolkit.StringUtils;
import com.manage.utils.Criteria;

/**
 * @author Fitch
 */
public class CustomerProvider {

    public String findPage(Criteria criteria){
        StringBuffer sql = new StringBuffer();
        sql.append(" select * from customer");
        sql.append(" where 1=1 ");
        this.getWhereSql(criteria);
        if (criteria.getOffset() != null) {
            sql.append(" limit #{offset},#{fetchSize}");
        }
        return sql.toString();
    }
    private String getWhereSql(Criteria criteria) {
        StringBuilder sql = new StringBuilder("");
        if (StringUtils.isNotEmpty(criteria.getString("name"))) {
            sql.append(" and name =#{condition.name}");
        }
        return sql.toString();
    }
}
